<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算属性 和 methods 的比较</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
    <div id="app">
        <h2>{{ getfullName() }}</h2>
        <h2>{{ getfullName() }}</h2>
        <h2>{{ getfullName() }}</h2>
        <h2>{{ getfullName() }}</h2>
        <h2>{{ fullName }}</h2>
        <h2>{{ fullName }}</h2>
        <h2>{{ fullName }}</h2>
        <h2>{{ fullName }}</h2>
    </div>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                firstName: "Kobe",
                lastName: "Bryant"
            },
           methods: {
               getfullName: function() {//调用几次就执行几次
                   console.log("getfullName 是methods")
                   return this.firstName + '' + this.lastName
               }
           },
           computed: {//数据未改变只执行一次
               fullName() {
                   console.log("fullName 是计算属性");
                return this.firstName + '' + this.lastName
               }
           }
        })
    </script>
</body>
</html>